package old2.Map;

import java.util.*;

public class MapDemo2 {
    public static void main(String[] args) {
        HashMap<String, Integer> map = new HashMap<>();
        map.put("语文",98);
        map.put("数学",99);
        map.put("化学",96);
        map.put("物理",92);

        Set<String> set = map.keySet();
        for(String key : set){
            System.out.println("Key"+key);
        }
        Set<Map.Entry<String, Integer>> entries = map.entrySet();
        System.out.println(entries);
        for (Map.Entry<String, Integer> e : entries){
            String key = e.getKey();
            Integer value = e.getValue();
            System.out.println(key+":"+value);

        }
        Collection<Integer> values = map.values();
        for(Integer value : values){
            System.out.println("value:"+value);

            Collection<String> c = new ArrayList<>();
            c.add("1");
            c.add("2");
            c.add("3");
            c.add("4");
            c.add("5");
            for (String e:c){
                System.out.println(e);
            }
            c.forEach(e-> System.out.println(e));

            map.forEach(
                    (k,v)-> System.out.println(k+":"+v)
            );
        }
    }

}
